<?php
/**
 * Created by PhpStorm.
 * User: 123
 * Date: 2021/4/8
 * Time: 11:25
 */
namespace app\adminapi\validate;

use think\Validate;

class Base extends Validate
{

    /**
     * 手机号验证
     * @param $value
     * @param $rule
     * @param $data
     * @return bool
     */
    protected function checkMobile($value, $rule, $data)
    {
        if($this->regex($value, "^1\d{10}$")) return true;
        return false;
    }

    /**
     * 验证码是否正确
     * @param $value
     * @param $rule
     * @param $data
     * @return bool
     */
    protected function codeEquality($value, $rule, $data)
    {
        $captcha = new \think\captcha\Captcha();
        if(!$captcha->check($value)) return false;
        return true;
    }
}